package com.shutuo.callnumqixintian.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class ShardPreferencesUtil {

    public static String getAppkey(Context context , String appkey) {
        String value = null;
        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        if (!preferences.contains("appkey")) {
            preferences.edit().putString("appkey", appkey).apply();
        } else {
            value = preferences.getString("appkey", "");
        }

        return value;
    }

    public static void saveAppkey(Context context , String appkey){

        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        preferences.edit().putString("appkey", appkey).apply();
    }

    public static String getAppId(Context context , String appid) {
        String value = null;
        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        if (!preferences.contains("appid")) {
            preferences.edit().putString("appid", appid).apply();
        } else {
            value = preferences.getString("appid", "");
        }
        return value;
    }

    public static void saveAppId(Context context , String appid){

        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        preferences.edit().putString("appid", appid).apply();
    }

    public static long getShopId(Context context , long shop_id) {
        long value = 0;
        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        if (!preferences.contains("shop_id")) {
            preferences.edit().putLong("shop_id", shop_id).apply();
        } else {
            value = preferences.getLong("shop_id", 0);
        }
        return value;
    }

    public static void saveShopId(Context context , long shop_id){

        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        preferences.edit().putLong("shop_id", shop_id).apply();
    }

    public static long getCashierId(Context context , long cashier_id) {
        long value = 0;
        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        if (!preferences.contains("cashier_id")) {
            preferences.edit().putLong("cashier_id", cashier_id).apply();
        } else {
            value = preferences.getLong("cashier_id", 0);
        }
        return value;
    }

    public static void saveCashierId(Context context , long cashier_id){

        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        preferences.edit().putLong("cashier_id", cashier_id).apply();
    }


    public static String getSNCode(Context context , String snCode) {
        String value = null;
        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        if (!preferences.contains("snCode")) {
            preferences.edit().putString("snCode", snCode).apply();
        } else {
            value = preferences.getString("snCode", "");
        }

        return value;
    }

    public static void saveSNCode(Context context , String snCode){

        SharedPreferences preferences = context.getSharedPreferences("socket", Context.MODE_PRIVATE);
        preferences.edit().putString("snCode", snCode).apply();
    }

}
